#!/bin/bash
PWD=$(cd `dirname $0`;pwd);
if [ -z $1 ]
then
	exit
fi
git add *
git commit -am $1
git pull
if [ -z $2 ]
then
	git push
else
	rm ./dist -rf
	cp src/utils/url.js src/utils/url.js_temp
	cp src/utils/url.js_simple src/utils/url.js
	case $2 in
	  dev)
	    BASEURL='https:\/\/crm-dev.jingqiweb.com'
	    SETTING='[dev]'
	    ;;
	  test)
	    BASEURL='https:\/\/crm-test.jingqiweb.com'
	    SETTING='[test]'
	    ;;
	  online)
	    BASEURL='https:\/\/webi.jingqiweb.com'
	    SETTING='[online]'
	    ;;
	  *)
	    ;;
	esac
	sed -i "s/{domain}/${BASEURL}/g" src/utils/url.js
	npm run build
	mv src/utils/url.js_temp src/utils/url.js
	git add *
	git add dist -f
	git add dist/* -f
	git commit -am "${SETTING}update"
	git push
fi
